<template name="shopdetailCom0">
	<view class="shopdetailCom shopdetailCom0">
		<view class="shopsw">
			<view :class="shopindex==0?'target':''" @click="shopswFun(0)">基本信息</view>
			<view :class="shopindex==1?'target':''" @click="shopswFun(1)">交易/积分</view>
			<!-- <view :class="shopindex==2?'target':''" @click="shopswFun(2)">拜访小记</view> -->
		</view>
		<view class="shopmodule">
			<view class="module_base module_info" v-show="shopindex==0">
				<view class="module_title">商户基本信息</view>
				<view class="module_content info_content">
					<view class="info_eve">
						<view class="info_eve_title">费率政策</view>
						<view @click="powSw">
							<text>{{basedata.rate_type}}政策</text>
							<image src="../../../static/img/my_back.png" style="width: 32rpx;height: 32rpx;vertical-align: middle;"></image>
						</view>
					</view>
					<view class="info_eve">
						<view class="info_eve_title">基础支付</view>
						<view>{{basedata.basepay_bind_status?'已':'未'}}绑定</view>
					</view>
					<view class="info_eve">
						<view class="info_eve_title">外卖门店</view>
						<view>{{basedata.waimai_bind_status?'已':'未'}}绑定</view>
					</view>
					<view class="info_eve">
						<view class="info_eve_title">经营类目</view>
						<view>{{basedata.category}}</view>
					</view>
					<view class="info_eve">
						<view class="info_eve_title">营业时间</view>
						<view>{{basedata.shop_time}}</view>
					</view>
					<view class="info_eve">
						<view class="info_eve_title">门店联系人</view>
						<view>{{basedata.realname}}</view>
					</view>
					<view class="info_eve">
						<view class="info_eve_title">门店联系电话</view>
						<view class="info_eve_phone" @click="makePhone(basedata.phone)">{{basedata.phone}}</view>
					</view>
					<view class="info_eve info_address">
						<view class="info_eve_title">门店地址</view>
						<view>
							<image @click="navAddress()" src="../../../static/img/ic_location_2.png"></image>
						</view>
					</view>
					<view class="info_eve">
						<view>{{basedata.address}}</view>
					</view>
					<view class="info_eve">
						<view class="info_eve_title">注册时间</view>
						<view>{{basedata.createtime}}</view>
					</view>
					<view class="info_eve">
						<view class="info_eve_title">认证通过时间</view>
						<view>{{basedata.passed_time}}</view>
					</view>
					<view class="info_eve">
						<view class="info_eve_title">支付绑定时间</view>
						<view>{{basedata.bind_agency_time}}</view>
					</view>
				</view>
				<view class="module_content info_content" style="margin-top: 20rpx;">
					<view class="info_eve">
						<view class="info_eve_title">BD</view>
						<view>{{basedata.salesman}}</view>
					</view>
					<view class="info_eve">
						<view class="info_eve_title">总代</view>
						<view>{{basedata.general_agency}}</view>
					</view>
				</view>
				<!-- <view style="height: 170rpx;"></view>
				<view class="module_base module_infoBtn">
					<view class="infoBtn">
						<button type="primary" @click="infoBtnfun()">跟进商户</button>
					</view>
				</view> -->
			</view>
		
			<view class="module_base module_trade" v-show="shopindex==1">
				<view class="module_title">商户交易信息</view>
				<view class="module_content trade_content">
					<view>
						<view class="trade_num">{{orderdata.month_amount}}</view>
						<view>本月收入</view>
					</view>
					<view>
						<view class="trade_num">{{orderdata.total_amount}}</view>
						<view>总收入</view>
					</view>
					<view>
						<view class="trade_num">{{orderdata.month_order}}</view>
						<view>本月交易笔数</view>
					</view>
					<view>
						<view class="trade_num">{{orderdata.total_order}}</view>
						<view>总交易笔数</view>
					</view>
				</view>
				<view class="module_title">刷脸交易信息</view>
				<view class="module_content trade_content">
					<view>
						<view class="trade_num">{{orderdata.order_cnt}}</view>
						<view>刷脸设备总笔数</view>
					</view>
					<view>
						<view class="trade_num">{{orderdata.order2_cnt}}</view>
						<view>刷脸设备有效笔数</view>
					</view>
					<view>
						<view class="trade_num">{{orderdata.amount_cnt}}</view>
						<view>刷脸设备总金额</view>
					</view>
					<view>
						<view class="trade_num">{{orderdata.amount2_cnt}}</view>
						<view>刷脸设备有效金额</view>
					</view>
				</view>
			</view>
		</view>
		
		<u-popup v-model="powerrate.show" mode="center" border-radius="14">
			<view class="powerPop">
				<view class="powerPop_title">政策切换</view>
				<view class="powerPop_con">
					<view class="powerPop_sw" @click="typeSw('A')">
						<image v-show="powerrate.type=='A'" src="../../../static/img/ic_choose.png"></image>
						<image v-show="powerrate.type=='B'" src="../../../static/img/ic_choose_n.png"></image>
						<text>A政策</text>
					</view>
					<view class="powerPop_sw" @click="typeSw('B')">
						<image v-show="powerrate.type=='B'" src="../../../static/img/ic_choose.png"></image>
						<image v-show="powerrate.type=='A'" src="../../../static/img/ic_choose_n.png"></image>
						<text>B政策</text>
					</view>
				</view>
				<view class="powerPop_input" v-if="powerrate.type=='A'">
					<input type="text" v-model="powerrate.rate" placeholder="请输入23-300(万分数)" />
					<text>设置费率</text>
				</view>
				<view class="powerPop_btn">
					<view @click="powerrate.show=false">取消</view>
					<view class="btn_sure" @click="powerSure">确定</view>
				</view>
			</view>
		</u-popup>
		
	</view>
</template>

<script>
	import { shopdetailbase,shopdetailorder,changeshoprate } from '../../../api/index.js'
	export default {
		name: "shopdetailCom0",
		data() {
			return {
				shopindex:0,
				basedata:{},
				orderdata:{},
				//费率弹窗对象
				powerrate:{
					type:'', //当前显示的政策
					show:false, //弹窗是否显示
					rate:'' //费率值
				}
			}
		},
		props:{
			suid:''
		},
		mounted: function() {
			this.getShopdetailbase()
			this.getShopdetailorder()
		},
		methods: {
			//获取商户基本信息
			getShopdetailbase:function(){
				let that = this;
				shopdetailbase({id:this.suid}).then((res) => {
					console.log(res)
					if(res.code == 0){
						that.basedata = res.data;
						that.powerrate.type = that.basedata.rate_type;
						that.$emit('editdataFun',that.basedata);
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				}).catch((e) => {
					console.log(e)
				})
			},
			//获取商户交易/积分信息
			getShopdetailorder:function(){
				let that = this;
				shopdetailorder({id:this.suid}).then((res) => {
					console.log(res)
					if(res.code == 0){
						that.orderdata = res.data;
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				}).catch((e) => {
					console.log(e)
				})
			},
			shopswFun:function(index){
				if(index==2){
					uni.showToast({
						icon:'none',
						title:'功能正在开发中'
					})
					return ;
				}
				this.shopindex = index;
			},
			//政策切换
			powSw:function(){
				this.powerrate.show = true;
			},
			typeSw:function(type){
				this.powerrate.type = type;
			},
			//确定修改政策
			powerSure:function(){
				if(this.powerrate.type=='A'){
					if(!this.powerrate.rate){
						uni.showToast({
							title: '请输入费率',
							icon: 'none'
						})
						return ;
					}else if(this.powerrate.rate<23 || this.powerrate.rate>300){
						uni.showToast({
							title: '请输入23-300(万分数)',
							icon: 'none'
						})
						return ;
					}
				}
				if(this.basedata.rate_type == this.powerrate.type == 'B'){
					uni.showToast({
						title: '不可重复选择B政策',
						icon: 'none'
					})
					return ;
				}
				let rate = this.powerrate.type=='B'?'38':this.powerrate.rate;
				
				changeshoprate({
					id:	this.basedata.id,//门店id
					rate:rate//费率值
				}).then((res) => {
					console.log(res)
					if(!res.code){
						uni.showToast({
							title: '设置成功',
							icon: 'none'
						})
						this.powerrate.show = false;
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				}).catch((e) => {
					console.log(e)
				})
			},
			//拨打电话
			makePhone:function(phone){
				cm.makePhoneCall({
					phone:phone
				});
			},
			//跳转到高德地图
			navAddress:function(){
				let that = this;
				if(!that.basedata.longitude || !that.basedata.latitude){
					uni.showToast({
						title: "经纬度不能为空",
						icon: 'none'
					})
					return ;
				}
				if(!that.basedata.address){
					uni.showToast({
						title: "地址不能为空",
						icon: 'none'
					})
					return ;
				}
				cm.jumpMap({
					longitude:that.basedata.longitude,
					latitude:that.basedata.latitude,
					destination:that.basedata.address
				})
			},
			infoBtnfun:function(){
				uni.showToast({
					icon:'none',
					title:'功能正在开发中'
				})
				return ;
			}
		},
		components: {
			
		}
	}
</script>

<style lang="scss" scoped>
	@import './shopdetailCom.scss';
	.module_infoBtn{
		padding: 30rpx;
		background-color: #fff;
	}
</style>
